home *** CD-ROM | disk | FTP | other *** search
- #ifndef FWEXCEPT_H
- #define FWEXCEPT_H
- //========================================================================================
- //
- // File: FWExcept.h
- // Release Version: $ 1.0d11 $
- //
- // Copyright: (c) 1993, 1995 by Apple Computer, Inc., all rights reserved.
- //
- //========================================================================================
-
- #ifndef FWCLAINF_H
- #include "FWClaInf.h"
- #endif
-
- #ifndef FWPRIDEB_H
- #include "FWPriDeb.h"
- #endif
-
- #if FW_LIB_EXPORT_PRAGMAS
- #pragma lib_export on
- #endif
-
- //========================================================================================
- // Exception classes definition and implementation macros
- //========================================================================================
-
- #define FW_DECLARE_EXCEPTION(name) \
- public: \
- FW_DECLARE_CLASS
-
- #define FW_DEFINE_EXCEPTION_ROOT(name) \
- FW_DEFINE_CLASS_M0(name)
-
- #define FW_DEFINE_EXCEPTION(name, ancestor) \
- FW_DEFINE_CLASS_M1(name, ancestor)
-
- //========================================================================================
- // CLASS _FW_XException
- //========================================================================================
-
- class FW_CLASS_ATTR _FW_XException
- {
- public:
- virtual ~_FW_XException();
- _FW_XException();
-
- size_t GetSize() const;
- // Returns the size of this object, using info from its metaclass
- // This method is not virtual, but will work correctly since PrivVirtualGetClassInfo is virtual.
-
- const char* GetClassName() const;
- // Returns the class name of this object, as a string.
- // This method is not virtual, but will work correctly since PrivVirtualGetClassInfo is virtual.
-
- virtual void Copy(void *p, size_t maxObjectSize) const;
- // Copies this object. This method does a bitwise copy, but subclasses
- // must override to perform a deep copy.
-
- #ifndef FW_NATIVE_EXCEPTIONS
- int PrivIsKindOf(FW_ClassInfoPtr aClass);
- // Returns 1 if this object is a kind of aClass, i.e. same or subclass of aClass.
-
- void PrivDelete();
- // Calls the virtual destructor, but does not attept to delete storage.
-
- #endif // FW_NATIVE_EXCEPTIONS
-
- #ifdef FW_DEBUG
- short fIsValid;
- #endif
-
- FW_DECLARE_EXCEPTION(_FW_XException)
-
- public:
- // these are provided to mask a bug in Borland C++ (it calls delete when
- // you just want to call the dtor, explicitly)
- void* operator new(size_t size);
- void operator delete(void* memory);
- };
-
- //========================================================================================
- // CLASS _FW_XException inline functions
- //========================================================================================
-
- inline size_t _FW_XException::GetSize() const
- {
- FW_PRIV_ASSERT(fIsValid==1);
- return PrivVirtualGetClassInfo()->GetInstanceSize();
- }
-
- inline const char* _FW_XException::GetClassName() const
- {
- FW_PRIV_ASSERT(fIsValid==1);
- return PrivVirtualGetClassInfo()->GetClassName();
- }
-
- #ifndef FW_NATIVE_EXCEPTIONS
-
- inline void _FW_XException::PrivDelete()
- {
- FW_PRIV_ASSERT(fIsValid==1);
- #ifdef _MPWCFRONT
- // MPW CFront is not supported with this version of the code
- FW_PRIV_ASSERT(FALSE);
- // CFront is bizarre. It won't allow the unscoped destructor name, but the scoped
- // name is dispatched virtually, even though ARM says scoped names are never virtual.
- this->_FW_XException::~_FW_XException();
- #else
- this->~_FW_XException(); // Virtual dispatch to object's destructor
- #endif
- FW_PRIV_ASSERT(fIsValid == 0);
- }
-
- #endif // FW_NATIVE_EXCEPTIONS
-
- #if FW_LIB_EXPORT_PRAGMAS
- #pragma lib_export off
- #endif
-
- #endif
-